package week_08;

import week_07.Queue;

public class BinaryTreeText {
    public static void main(String[] args) {
        BinaryTree<String, String> tree = new BinaryTree<>();
        tree.put("E","5");
        tree.put("B","2");
        tree.put("G","7");
        tree.put("A","1");
        tree.put("D","4");
        tree.put("F","6");
        tree.put("H","8");
        tree.put("C","3");

        Queue<String> keysPre = tree.preErgodic();
        Queue<String> keysMid = tree.midErgodic();
        Queue<String> keysAft = tree.afterErgodic();
        System.out.println("前序遍历");
        for (Object key : keysPre) {
            String value = tree.get((String) key);
            System.out.println(key+"---"+value);
        }
        System.out.println("---------------------");
        System.out.println("中序遍历");
        for (Object key : keysMid) {
            String value = tree.get((String) key);
            System.out.println(key+"---"+value);
        }
        System.out.println("---------------------");
        System.out.println("后序遍历");
        for (Object key : keysAft) {
            String value = tree.get((String) key);
            System.out.println(key+"---"+value);
        }

        Queue<String> keysLayer = tree.layerErgodic();
        System.out.println("---------------------");
        System.out.println("层序遍历");
        for (Object key : keysLayer) {
            String value = tree.get((String) key);
            System.out.println(key+"---"+value);
        }
    }
}
